package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.SellDetailBean;
import com.project.bean.SellOrderBean;
import com.project.mapper.ISellOrderMapper;
import com.project.service.ISellOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;

@RestController
@RequestMapping("sellOrder")
@Api(tags = "销售订单控制器")
public class SellOrderController {
    @Autowired
    private ISellOrderService service;

    @RequiresPermissions("sell:find")
    @RequestMapping("cutByItem")
    @ApiOperation(value = "销售订单分页", notes = "销售订单分页")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageNO", value = "页码", required = true),
            @ApiImplicitParam(name = "cName", value = "客户名称"),
            @ApiImplicitParam(name = "startDate", value = "销售起始日期"),
            @ApiImplicitParam(name = "endDate", value = "销售结束日期")
    })
    public IPage<SellOrderBean> cutByItem(Integer pageNO, String cName, LocalDate startDate, LocalDate endDate) {
        return service.cutByItem(pageNO, cName, startDate, endDate);
    }

    @RequiresPermissions("sell:find")
    @RequestMapping("findDetailByOrderId")
    @ApiOperation(value = "根据销售订单id查看销售明细", notes = "根据销售订单id查看销售明细")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "sellOrderId", value = "销售订单id")
    })
    public SellOrderBean findDetailByOrderId(Integer sellOrderId) {
        return service.findDetailByOrderId(sellOrderId);
    }
}
